package com.kuaimacode.kframework.component;

import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;

/**
 * @author qinyong
 * @Title:
 * @Package com.kuaimacode.kframework.component
 * @Description: created by IntelliJ IDEA
 * @date 2019-03-25 21:32
 */
@Component
public class ComponentUtil {

    @Value("${project.domain}")
    private String domain;
    @Value("${img.upload.location.img}")
    private String imgPath;


    /**
     * 转换图片路径
     * @param relativePath
     * @return
     */
    public final String convertImgUrl(String relativePath) {
        if (StringUtils.isBlank(relativePath)) {
            return relativePath;
        }
        return domain + imgPath + relativePath;
    }


    public final String convertImgAdminUrl(String relativePath) {
        if (StringUtils.isBlank(relativePath)) {
            return relativePath;
        }
        return domain + relativePath;
    }
}
